
function FormObj(pdObjs) {
	this.nID = null;
	this.position = []; // [l,t,r,b]
	this.form = null; // a PDForm
	this.matrix = []; // form matrix
	this.nGenStateID = -1;
	this.nClrStateID = -1;
	this.nGraphStateID = -1;
	this.nTextStateID = -1;
	this.nClipPathStateID = -1;

	this.m_pdObjs = pdObjs;

	this.GetBBox = function (mtObj2Dev) {
	    var rect = mtObj2Dev.TransFormRect(this.position[0], this.position[1], this.position[2], this.position[3]);
	    return rect;
	}
}

// set up prototype inheritance chain
setupInheritPrototype(FormObj, PageObj);

FormObj.prototype.SetID = function(formID) {
	this.nID = formID;
};

FormObj.prototype.GetID = function() {
	return this.nID;
};

FormObj.prototype.SetPosition = function(position) {
	this.position = stringArr2NumArr(position);
};

FormObj.prototype.GetPosition = function() {
	return this.position;
};

FormObj.prototype.GetForm = function() {
	return this.form;
};

FormObj.prototype.ParseJson = function(arrayData) {
	//var tempFormObj = this;
	this.SetID(arrayData[1]);
	this.SetPosition(stringArr2NumArr(arrayData[2]));
	this.form = PDForm.prototype.FromJson(arrayData[9]);
	this.SetMatrix(stringArr2NumArr(arrayData[3]));
	this.nGraphStateID = arrayData[6];
	this.nClrStateID = arrayData[7];
	this.nTextStateID = arrayData[8];
	this.nGenStateID = arrayData[4];
	this.nClipPathStateID = arrayData[5];
};


FormObj.prototype.ParseFromBin = function (rd) {
	// the type id has been read
	this.SetID(rd.readInt32());
	this.matrix = this.m_pdObjs.GetMatrixByID(rd.readUint16());
	for (var i = 0; i < 4; i++) {this.position.push(rd.readFloat32());}
	this.form = new PDForm(this.m_pdObjs.m_pdDoc, this.m_pdObjs.m_csImgPath);
	this.form.ParseFromBin(rd);
};
